<?php
namespace app\shop\model\company;

use think\Model;
use app\shop\model\user\User;
use think\model\concern\SoftDelete;
/**
 * 应用模型
 */
class WorkReport extends Model
{
    use SoftDelete;
    protected $autoWriteTimestamp = true;

    const STATUS_ON = 0;    //进行中
    const STATUS_FINISH = 1;    //已完成
    const STATUS_TIMEOUT = 2;    //已超时

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'user_id');
    }

    public function department()
    {
        return $this->belongsTo(Department::class, 'department_id', 'id');
    }

    public function station()
    {
        return $this->belongsTo(Station::class, 'station_id', 'id');
    }

    public function getTypeNameAttr($value, $data)
    {
        $type = [
            1 => '日报',
            2 => '周报',
            3 => '月报',
        ];
        return $type[$data['type'] ?? 1];
    }
}
